package com.eims.sls_app.ui;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.webkit.JavascriptInterface;
import android.webkit.WebSettings;
import android.webkit.WebView;
import bls.juejin.cn.R;

public class WebViewPayACtivity extends MyBaseActivity {
	public WebView webView;
	private WebSettings mWebSettings;
	boolean isfirst = false;
private String price,outer_no;
	@SuppressLint("NewApi")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.webview_play);

		Bundle bundle=getIntent().getExtras();
		price=bundle.getString("price");
		outer_no=bundle.getString("outer_no");
		// 加载页面
		webView = (WebView) findViewById(R.id.webview);

		WebSettings s = webView.getSettings();
		s.setBuiltInZoomControls(true);

		s.setUseWideViewPort(true);
		s.setLoadWithOverviewMode(true);
		s.setSavePassword(true);
		s.setSaveFormData(true);
		s.setJavaScriptEnabled(true); // enable navigator.geolocation
		s.setGeolocationEnabled(true);
		webView.addJavascriptInterface(new Object() {
			 @JavascriptInterface
			 public void startMap() { 
				 webView.loadUrl("javascript:clickToPay2('" + price+"','"+outer_no+ "')");  
			}
		
	        }, "demo"); 
		// 允许JavaScript执行
		// 找到Html文件，也可以用网络上的文件
		webView.loadUrl("file:///android_asset/index.html");
//		webView.loadUrl("javascript：test('" + price+"','"+outer_no+ "')");;// 调用js函数

	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		if (isfirst) {
			finish();
		}
		isfirst = !isfirst;

	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);

		finish();

	}
}
